;;------------------------------------------------------
;; NCL function for system utils 
;; written by Kai Zhang, MPI-M  
;; 2009-04-15 
;;------------------------------------------------------


;;------------------------------------------------------
  undef("sysclear")
;;------------------------------------------------------

  function sysclear()

  begin

   system("clear") 

   return(0)
 
  end


;;------------------------------------------------------
  undef("syscheck")
;;------------------------------------------------------

  function syscheck(ierr)

  begin

   if (ierr.ne.0) then 
      print(" ") 
      print(" ") 
      print(" ") 
      print(" syscheck error !!!") 
      print(" ") 
      print(" ") 
      print(" ") 
      exit 
   end if  

   return(0)

  end


;;------------------------------------------------------
  undef("sysfile")
;;------------------------------------------------------

  function sysfile(na,filename)

  begin

   ;; file-exist-test  
 
   if (na.eq.0) then 

     if (isfilepresent(filename)) then
        ;;print(" ") 
        ;;print("system --- file "+filename+" found ")
        ;;print(" ") 
     else
        print(" ") 
        print("system --- file "+filename+" not found !!!")
        print(" ") 
        exit
     end if

   end if 

   ;; delete-file-filename

   if (na.eq.1) then 
      ;;print(" ") 
      system("rm "+filename)  
      ;;print("system --- file "+filename+" is deleted") 
      ;;print(" ") 
   end if 

   ;; delete-file-withfilename

   if (na.eq.2) then
      ;;print(" ")
      system("rm "+filename+"*")
      ;;print("system --- file "+filename+"* is deleted")
      ;;print(" ")
   end if

   if (na.eq.3) then
      ;;print(" ")
      system("cp "+filename+" "+filename+".cp")
      ;;print("system --- file "+filename+" is copied to "+filename+".cp")
      ;;print(" ")
   end if

   return(0)

  end

















